package com.neutech.shop.mapper.impl;

import com.neutech.shop.entity.Category;
import com.neutech.shop.mapper.CategoryMapper;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Neuedu-远哥
 * @version 1.0
 * @date 2021/9/27 9:22
 */
@Repository
public class CategoryMapperImpl extends SqlSessionDaoSupport implements CategoryMapper {
    @Resource
    @Override
    public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
        super.setSqlSessionFactory(sqlSessionFactory);
    }

    @Override
    public void insertRootCategory(String name,String descr) {
        getSqlSession().getMapper(CategoryMapper.class).insertRootCategory(name,descr);
    }

    @Override
    public List<Category> selectAll() {
        return getSqlSession().getMapper(CategoryMapper.class).selectAll();
    }

    @Override
    public Category selectByParentId(Integer pid) {
        return getSqlSession().getMapper(CategoryMapper.class).selectByParentId(pid);
    }

    @Override
    public void updateParentLeaf(Integer pid) {
        getSqlSession().getMapper(CategoryMapper.class).updateParentLeaf(pid);
    }

    @Override
    public void insertChildCategory(Category category) {
        getSqlSession().getMapper(CategoryMapper.class).insertChildCategory(category);
    }

    @Override
    public List<Category> selectThirdGrade() {
        return getSqlSession().getMapper(CategoryMapper.class).selectThirdGrade();
    }

}
